﻿
#include "livewatch.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    WatchView watch;         //视图
    WatchDelegate delegate;  //委托
    WatchModel model;        //模型
    delegate.setTailIndex(model.getTailIndex());  //委托需要保存模型的最后一行<click to add>的索引
    //当点击<click to add>时，模型中要追加一行监控数据
    watch.connect(&delegate, &WatchDelegate::clickToAdd, &model, &WatchModel::appendRow);
    watch.setItemDelegate(&delegate);   //为视图设置自定义委托
    watch.setModel(&model);             //为视图设置模型
    watch.show();

    return a.exec();
}
